function [ all, c, ax, vx  ] = PMCC(samples,sr)

win = 400; 
hopfactor = 0.4;
p = 60;

samples = filter([1 -0.97], 1, samples);

hop = win*hopfactor;
Z = buffer(samples,win,win-hop);
Q = size(Z,2);
hamming_okno = hamming(win);
oknovane_ramce_all = [];
for q = 1:Q
    wind = Z(:,q);
    oknovane_ramce = hamming_okno.*wind;
    oknovane_ramce_all = [oknovane_ramce_all oknovane_ramce];
    X = oknovane_ramce_all;
end

%X_fft = real(fft(abs(X).^2));
X_fft=(real(fft(X,400)));

%XX = audspec(X_fft, sr, 120, 'bark', 0, sr/2, 1, 1);

       
Sa_all = [];
Sp_all = [];
Sb_all = [];

for i = 1:Q,
    ramec_MVDR = X_fft(:,i);
    [Sa,Sb,Sp] = pmvdr_PMCC(ramec_MVDR,p);
    Sa_all = [Sa_all Sa];
Sp_all = [Sp_all Sp];
Sb_all = [Sb_all Sb];    
end

Sb_all = audspec(Sb_all, sr, 120, 'bark', 0, sr/2, 1, 1);

%Sb_all=real(fft(Sb_all,400));
y = log((Sb_all));

c = real(ifft(y,240));

nbands = size(c,1);

c(14:nbands, :) = [];
for i = 1 : 13
           c(i, : ) = c(i, : ) - mean(c(i, : ));
end

c=c';

nf=size(c,1);
nc=13;

  vf=(4:-1:-4)/60;
  af=(1:-1:-1)/2;
  ww=ones(5,1);
  cx=[c(ww,:); c; c(nf*ww,:)];
  vx=reshape(filter(vf,1,cx(:)),nf+10,nc);
  vx(1:8,:)=[];
  ax=reshape(filter(af,1,vx(:)),nf+2,nc);
  ax(1:2,:)=[];
  vx([1 nf+2],:)=[];  
  all=[c vx ax];
  
  c=c';             %zakladne
  ax=ax';           %akceleracne
  vx=vx';           %diferencne
  all=all';         %vsetky 39
end
